package com.owc.controller.admin;

import com.owc.domain.BaseResult;
import com.owc.domain.dto.UserInfo;
import com.owc.domain.vo.admin.AdminLoginVo;
import com.owc.domain.vo.app.LoginVo;
import com.owc.service.admin.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author Jackies
 * @Date 2019/12/8 19:30
 * @Description TODO://
 **/
@RestController
@RequestMapping(value = "/admin")
@Api(tags = "User login interface")
public class AdminController {

    private final AdminService adminService;

    public AdminController(AdminService adminService) {
        this.adminService = adminService;
    }

    /**
     * Background management login
     * @return JWT token.
     */
    @PostMapping(value = "/login")
    @ApiOperation("Login.")
    public BaseResult<String> login(@RequestBody @Valid AdminLoginVo adminLoginVo){
        return BaseResult.success(adminService.login(adminLoginVo));
    }

    @PostMapping(value = "/getUserInfo")
    @ApiOperation("Fetch user info.")
    public BaseResult<UserInfo> getUserInfo(){
        return BaseResult.success(adminService.getUserInfo());
    }

}
